package com.qfedu.fmmall.controller;

import com.qfedu.fmmall.service.UsersService;
import com.qfedu.fmmall.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
@Api(value = "提供用户的登录和注册接口",tags = "用户管理")
public class UserController {
   @Resource
    private UsersService userService;
    //   http://localhost:8080/fmmall/user/login
   @ApiOperation(value = "用户登录接口")
   @ApiImplicitParams({@ApiImplicitParam(type = "string",name = "username",value = "用户登录账号",required = true),
   @ApiImplicitParam(type = "string",name = "password",value = "用户登录密码")})
   @GetMapping("/login")
    public ResultVO login( @RequestParam String username, @RequestParam(defaultValue = "1111") String password){
          return userService.login(username, password);
    }
    @GetMapping("/regist")
    @ApiOperation(value = "用户注册接口")
    @ApiImplicitParams({@ApiImplicitParam(type = "string",name = "username",value = "用户注册账号",required = true),
            @ApiImplicitParam(type = "string",name = "password",value = "用户注册密码",required = true)})
    public ResultVO regist( @RequestParam String username, @RequestParam String password){
        return userService.regist(username, password);
    }

}
